<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生信息管理系统 - 用户注册</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div class="container">
        <div class="form-container">
            <h1>用户注册</h1>
            
            <!-- 显示消息提示 -->
            <% if (request.getAttribute("message") != null) { %>
                <div class="message success">
                    <%= request.getAttribute("message") %>
                </div>
            <% } %>
            
            <% if (request.getAttribute("error") != null) { %>
                <div class="message error">
                    <%= request.getAttribute("error") %>
                </div>
            <% } %>
            
            <div class="error-container" style="display: none;"></div>
            
            <form id="registerForm" action="<%= request.getContextPath() %>/UserServlet" method="post" data-validate>
                <input type="hidden" name="action" value="register">
                <div class="form-group">
                    <label for="username">用户名</label>
                    <input type="text" id="username" name="username" required placeholder="请输入用户名">
                </div>
                
                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" id="password" name="password" required placeholder="请输入密码">
                    <small>密码至少8位，包含字母和数字</small>
                    <div id="password-strength" style="margin-top: 5px;"></div>
                </div>
                
                <div class="form-group">
                    <label for="confirmPassword">确认密码</label>
                    <input type="password" id="confirmPassword" name="confirmPassword" required placeholder="请再次输入密码">
                </div>
                
                <div class="form-group">
                    <label for="fullName">姓名</label>
                    <input type="text" id="fullName" name="fullName" required placeholder="请输入姓名">
                </div>
                
                <div class="form-group">
                    <label for="email">邮箱</label>
                    <input type="email" id="email" name="email" required placeholder="请输入邮箱">
                </div>
                
                <div class="form-group">
                    <label for="phone">手机号</label>
                    <input type="tel" id="phone" name="phone" required placeholder="请输入手机号">
                </div>
                
                <div class="form-group">
                    <label for="role">角色</label>
                    <select id="role" name="role" required>
                        <option value="">请选择角色</option>
                        <option value="admin">管理员</option>
                        <option value="teacher">教师</option>
                        <option value="student">学生</option>
                    </select>
                </div>
                
                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-block">注册</button>
                </div>
                
                <div style="text-align: center; margin-top: 20px;">
                    已有账号？<a href="login.jsp">立即登录</a>
                </div>
            </form>
        </div>
    </div>
    
    <script src="js/script.js"></script>
</body>
</html>